package com.well.register.console.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.well.register.console.domain.Job;
import com.well.register.console.domain.JobExecutor;
import com.well.register.console.domain.JobParam;
import com.well.register.console.model.job.QueryJobExecutorParam;
import com.well.rpc.model.DoJobResponseModel;
import com.well.rpc.model.RegisterModel;

import java.util.List;

/**
 * <p>
 * job executor service, 保存job执行记录。
 * </p>
 *
 * @author weedo
 * @since 2022/7/31
 */


public interface JobExecutorService extends IService<JobExecutor> {

    /**
     * 保存任务执行记录
     * @param jobName 任务名
     * @param registerModel 注册模型
     * @return
     */
    int saveExecutorInfo(String jobName, RegisterModel registerModel, Integer runType);

    /**
     * 获取Job信息
     * @param registerModel
     * @param jobName
     * @return
     */
    Job getJobInfo(RegisterModel registerModel, String jobName);

    /**
     * 更新Job
     * @param job
     */
    boolean updateJob(Job job, int thread_key);

    /**
     *  保存执行结果
     * @param responseModel
     * @return
     */
    boolean saveExecutorResult(DoJobResponseModel responseModel);

    /**
     * 查询执行记录
     * @param id
     * @return
     */
    Page<JobExecutor> getExecutorRecordsByJobId(QueryJobExecutorParam id);

    /**
     * 获取job参数
     * @param id
     * @return
     */
    List<JobParam> getJobParam(Integer id);
}
